<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"          			
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"  
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <ui:composition template="TaskProLayout.xhtml">
        <ui:define name="content">
            <div class="Post">
                <h:form id="teamForm">
                    <p:dataTable value="#{teamBean.teams}" var="team" selectionMode="single"
                                 selection="#{teamBean.selectedTeam}"
                                 rowKey="#{team.id}">
                        <f:facet name="header">  
                            <h:outputText value="Students teams" />     
                        </f:facet>  
                        <p:column headerText="Team name">
                            <h:outputText value="#{team.name}" />
                        </p:column>
                        <p:column headerText="Team group">
                            <h:outputText value="#{team.group.code}" />
                        </p:column><p:column headerText="Team subject">
                            <h:outputText value="#{team.group.subject.code}" />
                        </p:column>
                    </p:dataTable> <h:outputText value="To select or unselect use CTRL" /> <br/>
                    <p:commandButton value="Choose" action="#{teamBean.selectTeam()}" update=":studentsInTeam"/>  
                </h:form>
            </div>
            <div class="Post">
                <h:form id="studentsInTeam">  
                    <p:dataTable  rendered="#{teamBean.studentsRendered}"
                                  rowKey="#{student.login}"
                                  var="student" value="#{teamBean.finalStudents}"  
                                  >  
                        <f:facet name="header">  
                            <h:outputText value="Co-workers in team: #{teamBean.selectedTeam.name}" />     
                        </f:facet>  

                        <f:facet name="footer">  
                            <h:outputText value="" />     
                        </f:facet>  
                        <p:column headerText="Login">  
                            <h:outputText value="#{student.login}" />  
                        </p:column> 
                        <p:column headerText="Name">  
                            <h:outputText value="#{student.name}" />  
                        </p:column>  
                        <p:column headerText="Surname">  
                            <h:outputText value="#{student.surname}" />  
                        </p:column> 
                        <p:column headerText="Email">  
                            <h:outputText value="#{student.email}" />  
                        </p:column> 
                    </p:dataTable>  
                </h:form>
            </div>

        </ui:define>
    </ui:composition>



</html>